<?php
   
/**
 * Mapper for tratings
 * 
 * @author Martin Grossmann <snake.aas@gmail.com>
 * @version 1.0
 * @package Mappers
 *
 * @property int $idRating ID
 * @property User $User User that entered the comment
 * @property Photo $Photo Photo, which belongs to comment
 * @property int $Rating Rating
 * 
 * @entity
 * @table(name="tratings", indexes={@index(name="TComments_TPhotos_FK", columns="idPhoto")})
 * 
 */     
class Rating {
  /**
   *
   * @access private
   * @var int 
   * 
   * @Id
   * @column(name="idRating", type="integer")
   * @generatedValue
   */
  private $idRating;

  /**
   * User that entered the comment
   * 
   * @access private
   * @var User
   * 
   * @manyToOne(targetEntity="User", inversedBy="ratings")
   * @joinColumn(name="idUser", referencedColumnName="idUser")
   */
   private $user;
     
  /**
   * Photo, which belongs to comment
   * 
   * @access private
   * @var Photo
   * 
   * @manyToOne(targetEntity="Photo", inversedBy="ratings")
   * @joinColumn(name="idPhoto", referencedColumnName="idPhoto")
   */
   private $photo;
     
  /**
   * Text of a comment
   * 
   * @access private
   * @var string
   * 
   * @column(name="Value", type="text")
   */
   private $rating;
     

  public function __get($name) {
  
    switch($name) {
      case "idComment":
        return $this->idRating;
        break;
      
      case "User": 
        return $this->user;
        break;
   
      case "Photo": 
        return $this->photo;
        break;
    
      case "Rating": 
        return $this->rating;
        break;
      
      default: 
        throw new EntityException(sprintf(T_("Trying to get undefined property")." ", $name));
    }
  }
  
  public function __set($name, $value) {
        
    switch($name) {            
      case "User": 
        $this->user = Validations::ValidateObject($value, 'User');
        break; 

      case "Photo": 
        $this->photo = Validations::ValidateObject($value, 'Photo');
        break; 

      case "Rating": 
        $this->rating = Validations::validateInteger($value, 0, 5);
        break; 

      default: 
        throw new EntityException(sprintf(T_("Trying to set undefined property")." ", $name));
    }
  }  
  
  public function __construct() {
    
  }
  
  
}